<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:demo="http://omnifaces.org/showcase"
>
	<ui:define name="description">
		<p>
			The <code>&lt;o:methodParam&gt;</code> is a tag handler that can be used to pass a method expression into a 
			Facelets tag. By default this is not possible, and the expression that's intended to be a method expression
			will be created and made available as a value expression.
		</p>
		<p>
			This page demonstrates the passing of an EL reference to a method to a Facelets tag in a variety of 
			different ways. Note that the <code>&lt;demo:xxx&gt;</code> tags in the example are purely for demonstration,
			it should represent your own custom Facelets tag.
		</p>
	</ui:define>

	<ui:define name="demo">
		<h:form>
			<ul>
				<li>Action invoked: #{methodParamBean.actionInvoked}</li>
				<li>Listener invoked: #{methodParamBean.listenerInvoked}</li>
				<li>Lisitener with event invoked: #{methodParamBean.listenerWithEventInvoked}</li>
			</ul>

			<h3>Actions</h3>
			<p>
				Passing method with zero arguments
				<demo:actionmethod action="#{methodParamBean.doAction}" />
			</p>
			<p>
				Passing method with zero arguments but explicit parenthesis
				<demo:actionmethod action="#{methodParamBean.doAction()}" />
			</p>
			<p>
				Passing method with 1 view provided argument: 
				<demo:actionmethod action="#{methodParamBean.doActionWithParam('test')}" />
			</p>
			<p>
				Passing method to second bean with 1 view provided argument: 
				<demo:actionmethod action="#{methodParamBean.bean.doActionWithParam('test')}" />
			</p>

			<h3>Listeners</h3>
			<p>
				Passing listener method with zero arguments
				(always needs trick to pass!)
				<demo:actionlistenertrick listener="#{methodParamBean.actionListener}" />
			</p>
			<p>
				Passing listener method with zero arguments but explicit parenthesis
				(needs trick on older EL impl. like JBoss 6, not needed on AS 7)
				<demo:actionlistenertrick listener="#{methodParamBean.actionListener()}" />
			</p>
			<p>
				Passing listener method with 1 view provided argument: 
				<demo:actionlistener listener="#{methodParamBean.actionListenerWithParam('test')}" />
			</p>
			<p>
				Passing listener method with declared event parameter, no provided arguments
				<demo:actionlistener listener="#{methodParamBean.actionListenerWithClientParam}" />
			</p>

			<h3>Direct bindings</h3>
			<p>
				Direct binding (no method passing) with zero arguments: 
				<h:commandButton value="test" action="#{methodParamBean.doAction()}" />
			</p>
		 </h:form>
	</ui:define>
</ui:composition>